#region Copyright
//Copyright 2008 PivDev

//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at

//   http://www.apache.org/licenses/LICENSE-2.0

//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License. 
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.IO;
using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;

namespace CRMAddin
{
	public class ConfigValues
	{
		#region Field Configs
		protected string _FieldPrefix = "public const string ";
		private string _FieldSuffix = "";
		private string _FieldRegion = "";
		private bool _CapField = false;
		private string _FieldSubClass = "";
		private string _FieldSubClassPrefix = "";
		private string[ ] _FieldPrefixRemove = new string[ ] { };
		#endregion

		#region Table Configs
		private string _TableName = "Table_Name";
		private string _TableSuffix = "";
		private string _TablePrefix = "public const string ";
		private string _TableRegion = "";
		private bool _CapTable = false;
		private string[ ] _TablePrefixRemove = new string[ ] { };


		#endregion

		#region Query Configs

		private string _QuerySuffix = "";
		private string _QueryPrefix = "public const string";
		private string _QueryRegion = "";
		private bool _CapQuery = false;
		private string[ ] _QueryPrefixRemove = new string[ ] { };
		private string _QuerySubClass = "";
		private string _QuerySubClassPrefix = "public class ";
		private string[ ] _QueryReplaceChars = new string[ ] { };
		private string _QueryReplaceWith = "_";
		private bool _QueryReplaceEndChars = false;
		private bool _QueryReplaceStartChars = false;

		#endregion

		#region Data Build Configs

		private string[ ] _DBUsing = new string[ ] { };
		private string[ ] _DBInherits = new string[ ] { };
		private string[ ] _DBAddNamespaces = new string[ ] { };
		private string _DBClassPrefix = "public class ";
		private codeMethods[ ] _DBCodeMethods;
		private string[ ] _DBVariables = new string[ ] { };

		#endregion

		#region FormScript Configs
		private string[ ] _FSUsing = new string[ ] { };
		private string[ ] _FSInherits = new string[ ] { };
		private string[ ] _FSAddNamespaces = new string[ ] { };
		private string _FSClassPrefix = "public class ";
		private codeMethods[ ] _FSCodeMethods;
		private string[ ] _FSVariables = new string[ ] { };
		private fsMethods _FSMethods;

		#endregion

		#region Form Configs

		private string _FormPrefix = "public const string ";
		private string _FormSuffix = "";
		private string _FormRegion = "";
		private bool _CapForm = false;
		private string[ ] _FormPrefixRemove = new string[ ] { };
		private string[ ] _FormReplaceChars = new string[ ] { };
		private string _FormReplaceWith = "_";
		private bool _FormReplaceEndChars = false;
		private bool _FormReplaceStartChars = false;

		#endregion

		#region Disconnected Field Configs
		private string _DiscPrefix = "public const string ";
		private string _DiscSuffix = "";
		private string _DiscRegion = "";
		private bool _CapDisc = false;
		private string[ ] _DiscPrefixRemove = new string[ ] { };
		private string _DiscSubClass = "";
		private string _DiscSubClassPrefix = "";
		private bool _DiscUnique = true;
		private string[ ] _DiscReplaceChars = new string[ ] { };
		private string _DiscReplaceWith = "_";
		private bool _DiscReplaceEndChars = false;
		private bool _DiscReplaceStartChars = false;
		
		#endregion

		#region Tab Configs

		private string _TabPrefix = "public const string ";
		private string _TabSuffix = "";
		private string _TabRegion = "";
		private bool _CapTab = false;
		private string[ ] _TabPrefixRemove = new string[ ] { };
		private string[ ] _TabReplaceChars = new string[ ] { };
		private string _TabReplaceWith = "_";
		private bool _TabReplaceEndChars = false;
		private bool _TabReplaceStartChars = false;
		#endregion

		#region Seg Configs

		private string _SegPrefix = "public const string ";
		private string _SegSuffix = "";
		private string _SegRegion = "";
		private bool _CapSeg = false;
		private string[ ] _SegPrefixRemove = new string[ ] { };
		private string[ ] _SegReplaceChars = new string[ ] { };
		private string _SegReplaceWith = "_";
		private bool _SegReplaceEndChars = false;
		private bool _SegReplaceStartChars = false;
		#endregion

		#region Bespoke Classes
		public class codeMethods
		{
			private string _Region = "";
			private codeMethod[ ] _codeMethod;

			public codeMethod[ ] CodeMethod
			{
				get { return _codeMethod; }
				set { _codeMethod = value; }
			}

			public string Region
			{
				get { return _Region; }
				set { _Region = value; }
			}

		}
		public class codeMethod
		{
			private string _code = "";
			private bool _constructor = false;

			public string Code
			{
				get { return _code; }
				set { _code = value; }
			}

			public bool Constructor
			{
				get { return _constructor; }
				set { _constructor = value; }
			}
		}

		public class fsMethod
		{
			private bool _TryCatch = false;
			private string _Code = "";
			private bool _UseDefault = false;
			private string _Prefix = "";

			public string Prefix
			{
				get { return _Prefix; }
				set { _Prefix = value; }
			}
			public bool UseDefault
			{
				get { return _UseDefault; }
				set { _UseDefault = value; }
			}
			public string Code
			{
				get { return _Code; }
				set { _Code = value; }
			}
			public bool TryCatch
			{
				get { return _TryCatch; }
				set { _TryCatch = value; }
			}
		}
		public class fsMethods
		{
			private string _Region = "";
			private string _Prefix = "public ";

			private fsMethod _AddForm;
			private fsMethod _DeleteForm;
			private fsMethod _Execute;
			private fsMethod _LoadForm;
			private fsMethod _NewForm;
			private fsMethod _NewSec;
			private fsMethod _SaveForm;
			private fsMethod _SetSystem;

			public fsMethod SetSystem
			{
				get { return _SetSystem; }
				set { _SetSystem = value; }
			}
			public fsMethod SaveForm
			{
				get { return _SaveForm; }
				set { _SaveForm = value; }
			}
			public fsMethod NewSec
			{
				get { return _NewSec; }
				set { _NewSec = value; }
			}
			public fsMethod Execute
			{
				get { return _Execute; }
				set { _Execute = value; }
			}
			public fsMethod DeleteForm
			{
				get { return _DeleteForm; }
				set { _DeleteForm = value; }
			}
			public fsMethod AddForm
			{
				get { return _AddForm; }
				set { _AddForm = value; }
			}
			public fsMethod LoadForm
			{
				get { return _LoadForm; }
				set { _LoadForm = value; }
			}
			public fsMethod NewForm
			{
				get { return _NewForm; }
				set { _NewForm = value; }
			}

			public string Region
			{
				get { return _Region; }
				set { _Region = value; }
			}
			public string Prefix
			{
				get { return _Prefix; }
				set { _Prefix = value; }
			}
		}


		#endregion
		
		#region Getters & Setters

		public string SegReplaceWith
		{
			get { return _SegReplaceWith; }
			set { _SegReplaceWith = value; }
		}			
		public bool SegReplaceEndChars
		{
			get { return _SegReplaceEndChars; }
			set { _SegReplaceEndChars = value; }
		}
		public bool SegReplaceStartChars
		{
			get { return _SegReplaceStartChars; }
			set { _SegReplaceStartChars = value; }
		}
		public string[ ] SegReplaceChars
		{
			get { return _SegReplaceChars; }
			set { _SegReplaceChars = value; }
		}
		public bool TabReplaceStartChars
		{
			get { return _TabReplaceStartChars; }
			set { _TabReplaceStartChars = value; }
		}

		public string TabReplaceWith
		{
			get { return _TabReplaceWith; }
			set { _TabReplaceWith = value; }
		}
		public bool TabReplaceEndChars
		{
			get { return _TabReplaceEndChars; }
			set { _TabReplaceEndChars = value; }
		}

		public string[ ] TabReplaceChars
		{
			get { return _TabReplaceChars; }
			set { _TabReplaceChars = value; }
		}
		public bool DiscReplaceStartChars
		{
			get { return _DiscReplaceStartChars; }
			set { _DiscReplaceStartChars = value; }
		}

		public string DiscReplaceWith
		{
			get { return _DiscReplaceWith; }
			set { _DiscReplaceWith = value; }
		}


		public bool DiscReplaceEndChars
		{
			get { return _DiscReplaceEndChars; }
			set { _DiscReplaceEndChars = value; }
		}

		public string[ ] DiscReplaceChars
		{
			get { return _DiscReplaceChars; }
			set { _DiscReplaceChars = value; }
		}
		public bool FormReplaceStartChars
		{
			get { return _FormReplaceStartChars; }
			set { _FormReplaceStartChars = value; }
		}

		public bool FormReplaceEndChars
		{
			get { return _FormReplaceEndChars; }
			set { _FormReplaceEndChars = value; }
		}


		public string FormReplaceWith
		{
			get { return _FormReplaceWith; }
			set { _FormReplaceWith = value; }
		}



		public string[ ] FormReplaceChars
		{
			get { return _FormReplaceChars; }
			set { _FormReplaceChars = value; }
		}

		public string[ ] SegPrefixRemove
		{
			get { return _SegPrefixRemove; }
			set { _SegPrefixRemove = value; }
		}

		public bool CapSeg
		{
			get { return _CapSeg; }
			set { _CapSeg = value; }
		}

		public string SegRegion
		{
			get { return _SegRegion; }
			set { _SegRegion = value; }
		}

		public string SegSuffix
		{
			get { return _SegSuffix; }
			set { _SegSuffix = value; }
		}


		public string SegPrefix
		{
			get { return _SegPrefix; }
			set { _SegPrefix = value; }
		}

		public string[ ] TabPrefixRemove
		{
			get { return _TabPrefixRemove; }
			set { _TabPrefixRemove = value; }
		}

		public bool CapTab
		{
			get { return _CapTab; }
			set { _CapTab = value; }
		}

		public string TabRegion
		{
			get { return _TabRegion; }
			set { _TabRegion = value; }
		}

		public string TabSuffix
		{
			get { return _TabSuffix; }
			set { _TabSuffix = value; }
		}


		public string TabPrefix
		{
			get { return _TabPrefix; }
			set { _TabPrefix = value; }
		}

		
		public bool DiscUnique
		{
			get { return _DiscUnique; }
			set { _DiscUnique = value; }
		}

		public string DiscSubClass
		{
			get { return _DiscSubClass; }
			set { _DiscSubClass = value; }
		}
		public string DiscSubClassPrefix
		{
			get { return _DiscSubClassPrefix; }
			set { _DiscSubClassPrefix = value; }
		}
		
		public string[ ] DiscPrefixRemove
		{
			get { return _DiscPrefixRemove; }
			set { _DiscPrefixRemove = value; }
		}

		public bool CapDisc
		{
			get { return _CapDisc; }
			set { _CapDisc = value; }
		}

		public string DiscRegion
		{
			get { return _DiscRegion; }
			set { _DiscRegion = value; }
		}

		public string DiscSuffix
		{
			get { return _DiscSuffix; }
			set { _DiscSuffix = value; }
		}
		public string DiscPrefix
		{
			get { return _DiscPrefix; }
			set { _DiscPrefix = value; }
		}

		public string[ ] FormPrefixRemove
		{
			get { return _FormPrefixRemove; }
			set { _FormPrefixRemove = value; }
		}
		public bool CapForm
		{
			get { return _CapForm; }
			set { _CapForm = value; }
		}

		public string FormRegion
		{
			get { return _FormRegion; }
			set { _FormRegion = value; }
		}

		public string FormSuffix
		{
			get { return _FormSuffix; }
			set { _FormSuffix = value; }
		}


		public string FormPrefix
		{
			get { return _FormPrefix; }
			set { _FormPrefix = value; }
		}

		public fsMethods FSMethods
		{
			get { return _FSMethods; }
			set { _FSMethods = value; }
		}

		public string[ ] FSVariables
		{
			get { return _FSVariables; }
			set { _FSVariables = value; }
		}
		public codeMethods[ ] FSCodeMethods
		{
			get { return _FSCodeMethods; }
			set { _FSCodeMethods = value; }
		}

		public string FSClassPrefix
		{
			get { return _FSClassPrefix; }
			set { _FSClassPrefix = value; }
		}

		public string[ ] FSAddNamespaces
		{
			get { return _FSAddNamespaces; }
			set { _FSAddNamespaces = value; }
		}

		public string[ ] FSInherits
		{
			get { return _FSInherits; }
			set { _FSInherits = value; }
		}

		public string[ ] FSUsing
		{
			get { return _FSUsing; }
			set { _FSUsing = value; }
		}

		public string[ ] DBVariables
		{
			get { return _DBVariables; }
			set { _DBVariables = value; }
		}
		public codeMethods[ ] DBCodeMethods
		{
			get { return _DBCodeMethods; }
			set { _DBCodeMethods = value; }
		}
		public string DBClassPrefix
		{
			get { return _DBClassPrefix; }
			set { _DBClassPrefix = value; }
		}

		public string[ ] DBAddNamespaces
		{
			get { return _DBAddNamespaces; }
			set { _DBAddNamespaces = value; }
		}

		public string[ ] DBInherits
		{
			get { return _DBInherits; }
			set { _DBInherits = value; }
		}

		public string[ ] DBUsing
		{
			get { return _DBUsing; }
			set { _DBUsing = value; }
		}

		public bool QueryReplaceStartChars
		{
			get { return _QueryReplaceStartChars; }
			set { _QueryReplaceStartChars = value; }
		}

		public bool QueryReplaceEndChars
		{
			get { return _QueryReplaceEndChars; }
			set { _QueryReplaceEndChars = value; }
		}
		public string[ ] QueryReplaceChars
		{
			get { return _QueryReplaceChars; }
			set { _QueryReplaceChars = value; }
		}

		public string QueryReplaceWith
		{
			get { return _QueryReplaceWith; }
			set { _QueryReplaceWith = value; }
		}

		public string QuerySubClassPrefix
		{
			get { return _QuerySubClassPrefix; }
			set { _QuerySubClassPrefix = value; }
		}

		public string QuerySubClass
		{
			get { return _QuerySubClass; }
			set { _QuerySubClass = value; }
		}

		public string QueryRegion
		{
			get { return _QueryRegion; }
			set { _QueryRegion = value; }
		}

		public string[ ] QueryPrefixRemove
		{
			get { return _QueryPrefixRemove; }
			set { _QueryPrefixRemove = value; }
		}

		public bool CapQuery
		{
			get { return _CapQuery; }
			set { _CapQuery = value; }
		}

		public string QueryPrefix
		{
			get { return _QueryPrefix; }
			set { _QueryPrefix = value; }
		}

		public string QuerySuffix
		{
			get { return _QuerySuffix; }
			set { _QuerySuffix = value; }
		}

		public string[ ] FieldPrefixRemove
		{
			get { return _FieldPrefixRemove; }
			set { _FieldPrefixRemove = value; }
		}

		public string TablePrefix
		{
			get { return _TablePrefix; }
			set { _TablePrefix = value; }
		}

		public string TableSuffix
		{
			get { return _TableSuffix; }
			set { _TableSuffix = value; }
		}

		public string TableRegion
		{
			get { return _TableRegion; }
			set { _TableRegion = value; }
		}

		public bool CapTable
		{
			get { return _CapTable; }
			set { _CapTable = value; }
		}

		public string TableName
		{
			get { return _TableName; }
			set { _TableName = value; }
		}

		public string FieldSubClassPrefix
		{
			get { return _FieldSubClassPrefix; }
			set { _FieldSubClassPrefix = value; }
		}

		public string FieldSubClass
		{
			get { return _FieldSubClass; }
			set { _FieldSubClass = value; }
		}

		public bool CapField
		{
			get { return _CapField; }
			set { _CapField = value; }
		}

		public string FieldRegion
		{
			get { return _FieldRegion; }
			set { _FieldRegion = value; }
		}

		public string FieldSuffix
		{
			get { return _FieldSuffix; }
			set { _FieldSuffix = value; }
		}

		public string FieldPrefix
		{
			get { return _FieldPrefix; }
			set { _FieldPrefix = value; }
		}

		public string[ ] TablePrefixRemove
		{
			get { return _TablePrefixRemove; }
			set { _TablePrefixRemove = value; }
		}

		#endregion
	}

	public class ConfigRead
	{

		public ConfigRead ( ConfigValues objConfig , XmlDocument xmlDoc )
		{
			populateConfig( objConfig , xmlDoc );
		}

		private void DisplayConfigError ( string errorLine , int lineNumber )
		{
			string errorMessage = "Line number " + lineNumber.ToString( ) + " in the config file is incorrect" +
																							Environment.NewLine + Environment.NewLine +
																							errorLine +
																							Environment.NewLine + Environment.NewLine +
																							"Please correct before loading the configuration";
			MessageBox.Show( errorMessage , "Incorrect Config" , MessageBoxButtons.OK , MessageBoxIcon.Error );
		}

		private void populateConfig ( ConfigValues objConfig , XmlDocument xmlDoc )
		{



			XmlElement root = xmlDoc.DocumentElement;
			XmlNamespaceManager xmlnsmgr = new XmlNamespaceManager( xmlDoc.NameTable );
			xmlnsmgr.AddNamespace( "Pref" , "http://tempuri.org/config.xsd" );
			XmlNode prefNode = root.SelectSingleNode( "Field" , xmlnsmgr );

			#region Get values for Field parameters

			if (prefNode != null)
			{
				if (prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FieldPrefix = prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ) != null) objConfig.FieldSuffix = prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ) != null) objConfig.CapField = System.Convert.ToBoolean( prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ).InnerText );
				if (prefNode.SelectSingleNode( "Region" , xmlnsmgr ) != null) objConfig.FieldRegion = prefNode.SelectSingleNode( "Region" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "SubClass" , xmlnsmgr ) != null)
				{
					XmlNode scNode = prefNode.SelectSingleNode( "SubClass" , xmlnsmgr );
					if (scNode.SelectSingleNode( "Name" , xmlnsmgr ) != null) objConfig.FieldSubClass = scNode.SelectSingleNode( "Name" , xmlnsmgr ).InnerText;
					if (scNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FieldSubClassPrefix = scNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
				}
				if (prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr ) != null)
				{
					XmlNode prefixNode = prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr );

					objConfig.FieldPrefixRemove = new string[ prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ; i++)
					{
						objConfig.FieldPrefixRemove[ i - 1 ] = prefixNode.SelectSingleNode( "Prefix[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}

			}

			#endregion

			#region Get values for Table parameters

			prefNode = root.SelectSingleNode( "Table" , xmlnsmgr );
			if (prefNode != null)
			{
				if (prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ) != null) objConfig.CapTable = System.Convert.ToBoolean( prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ).InnerText );
				if (prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.TablePrefix = prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Region" , xmlnsmgr ) != null) objConfig.TableRegion = prefNode.SelectSingleNode( "Region" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ) != null) objConfig.TableSuffix = prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Name" , xmlnsmgr ) != null) objConfig.TableName = prefNode.SelectSingleNode( "Name" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr ) != null)
				{
					XmlNode prefixNode = prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr );

					objConfig.TablePrefixRemove = new string[ prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ; i++)
					{
						objConfig.TablePrefixRemove[ i - 1 ] = prefixNode.SelectSingleNode( "Prefix[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}
			}

			#endregion

			#region Get values for Query parameters

			prefNode = root.SelectSingleNode( "Query" , xmlnsmgr );
			if (prefNode != null)
			{
				if (prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ) != null) objConfig.CapQuery = System.Convert.ToBoolean( prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ).InnerText );
				if (prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.QueryPrefix = prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Region" , xmlnsmgr ) != null) objConfig.QueryRegion = prefNode.SelectSingleNode( "Region" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ) != null) objConfig.QuerySuffix = prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr ) != null)
				{
					XmlNode prefixNode = prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr );

					objConfig.QueryPrefixRemove = new string[ prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ; i++)
					{
						objConfig.QueryPrefixRemove[ i - 1 ] = prefixNode.SelectSingleNode( "Prefix[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}
				if (prefNode.SelectSingleNode( "SubClass" , xmlnsmgr ) != null)
				{
					XmlNode scNode = prefNode.SelectSingleNode( "SubClass" , xmlnsmgr );
					if (scNode.SelectSingleNode( "Name" , xmlnsmgr ) != null) objConfig.QuerySubClass = scNode.SelectSingleNode( "Name" , xmlnsmgr ).InnerText;
					if (scNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.QuerySubClassPrefix = scNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
				}

				if (prefNode.SelectSingleNode( "ReplaceChars" , xmlnsmgr ) != null)
				{
					XmlNode rcNode = prefNode.SelectSingleNode( "ReplaceChars" , xmlnsmgr );
					objConfig.QueryReplaceChars = new string[ rcNode.SelectNodes( "Char" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= rcNode.SelectNodes( "Char" , xmlnsmgr ).Count ; i++)
					{
						if (rcNode.SelectSingleNode( "Char[" + i + "]" , xmlnsmgr ).InnerText.ToUpper( ).Equals( "SPACE" )) objConfig.QueryReplaceChars[ i - 1 ] = " ";
						else objConfig.QueryReplaceChars[ i - 1 ] = rcNode.SelectSingleNode( "Char[" + i + "]" , xmlnsmgr ).InnerText;
					}
					if (rcNode.SelectSingleNode( "ReplaceWith" , xmlnsmgr ) != null) objConfig.QueryReplaceWith = rcNode.SelectSingleNode( "ReplaceWith" , xmlnsmgr ).InnerText;
					if (rcNode.SelectSingleNode( "RemoveWithCharsEnd" , xmlnsmgr ) != null) objConfig.QueryReplaceEndChars = System.Convert.ToBoolean( rcNode.SelectSingleNode( "RemoveWithCharsEnd" , xmlnsmgr ).InnerText );
					if (rcNode.SelectSingleNode( "RemoveWithCharsStart" , xmlnsmgr ) != null) objConfig.QueryReplaceStartChars = System.Convert.ToBoolean( rcNode.SelectSingleNode( "RemoveWithCharsStart" , xmlnsmgr ).InnerText );
				}
			}

			#endregion

			#region Get Values for Data Build

			prefNode = root.SelectSingleNode( "DataBuild" , xmlnsmgr );

			if (prefNode != null)
			{

				if (prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.DBClassPrefix = prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "ClassInherits" , xmlnsmgr ) != null)
				{
					XmlNode inheritsNode = prefNode.SelectSingleNode( "ClassInherits" , xmlnsmgr );
					objConfig.DBInherits = new string[ inheritsNode.SelectNodes( "Inherits" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= inheritsNode.SelectNodes( "Inherits" , xmlnsmgr ).Count ; i++)
					{
						objConfig.DBInherits[ i - 1 ] = inheritsNode.SelectSingleNode( "Inherits[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}
				if (prefNode.SelectSingleNode( "Usings" , xmlnsmgr ) != null)
				{
					XmlNode usingsNode = prefNode.SelectSingleNode( "Usings" , xmlnsmgr );
					objConfig.DBUsing = new string[ usingsNode.SelectNodes( "Using" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= usingsNode.SelectNodes( "Using" , xmlnsmgr ).Count ; i++)
					{
						objConfig.DBUsing[ i - 1 ] = usingsNode.SelectSingleNode( "Using[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}
				if (prefNode.SelectSingleNode( "Namespaces" , xmlnsmgr ) != null)
				{
					XmlNode nsNode = prefNode.SelectSingleNode( "Namespaces" , xmlnsmgr );
					objConfig.DBAddNamespaces = new string[ nsNode.SelectNodes( "Namespace" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= nsNode.SelectNodes( "Namespace" , xmlnsmgr ).Count ; i++)
					{
						objConfig.DBAddNamespaces[ i - 1 ] = nsNode.SelectSingleNode( "Namespace[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}

				if (prefNode.SelectSingleNode( "Methods" , xmlnsmgr ) != null)
				{


					objConfig.DBCodeMethods = new ConfigValues.codeMethods[ prefNode.SelectNodes( "Methods" , xmlnsmgr ).Count ];
					for (int j = 1 ; j <= objConfig.DBCodeMethods.Length ; j++)
					{

						XmlNode methNode = prefNode.SelectSingleNode( "Methods[" + j + "]" );
						if (methNode != null)
						{
							objConfig.DBCodeMethods[ j - 1 ] = new ConfigValues.codeMethods( );
							if (methNode.Attributes[ "region" ] != null) objConfig.DBCodeMethods[ j - 1 ].Region = methNode.Attributes[ "region" ].Value;
							if (methNode.SelectNodes( "Method" , xmlnsmgr ) != null)
							{
								objConfig.DBCodeMethods[ j - 1 ].CodeMethod = new ConfigValues.codeMethod[ methNode.SelectNodes( "Method" , xmlnsmgr ).Count ];

								for (int i = 1 ; i <= methNode.SelectNodes( "Method" , xmlnsmgr ).Count ; i++)
								{
									objConfig.DBCodeMethods[ j - 1 ].CodeMethod[ i - 1 ] = new ConfigValues.codeMethod( );
									objConfig.DBCodeMethods[ j - 1 ].CodeMethod[ i - 1 ].Code = methNode.SelectSingleNode( "Method[" + i + "]" , xmlnsmgr ).InnerText;
									if (methNode.SelectSingleNode( "Method[" + i + "]" , xmlnsmgr ).Attributes[ "constructor" ] != null) objConfig.DBCodeMethods[ j - 1 ].CodeMethod[ i - 1 ].Constructor = System.Convert.ToBoolean( methNode.SelectSingleNode( "Method[" + i + "]" , xmlnsmgr ).Attributes[ "constructor" ].Value );
									else objConfig.DBCodeMethods[ j - 1 ].CodeMethod[ i - 1 ].Constructor = false;
								}
							}
						}
					}
				}
				else objConfig.DBCodeMethods = new ConfigValues.codeMethods[ 0 ];
				if (prefNode.SelectSingleNode( "Variables" , xmlnsmgr ) != null)
				{
					XmlNode varNode = prefNode.SelectSingleNode( "Variables" , xmlnsmgr );

					objConfig.DBVariables = new string[ varNode.SelectNodes( "Variable" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= objConfig.DBVariables.Length ; i++)
					{
						objConfig.DBVariables[ i - 1 ] = varNode.SelectSingleNode( "Variable[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}
			}

			#endregion

			#region Get Values for Form Script Build
			prefNode = root.SelectSingleNode( "FormScriptBuild" , xmlnsmgr );

			if (prefNode != null)
			{
				#region Base Build
				if (prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FSClassPrefix = prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "ClassInherits" , xmlnsmgr ) != null)
				{
					XmlNode inheritsNode = prefNode.SelectSingleNode( "ClassInherits" , xmlnsmgr );
					objConfig.FSInherits = new string[ inheritsNode.SelectNodes( "Inherits" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= inheritsNode.SelectNodes( "Inherits" , xmlnsmgr ).Count ; i++)
					{
						objConfig.FSInherits[ i - 1 ] = inheritsNode.SelectSingleNode( "Inherits[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}
				if (prefNode.SelectSingleNode( "Usings" , xmlnsmgr ) != null)
				{
					XmlNode usingsNode = prefNode.SelectSingleNode( "Usings" , xmlnsmgr );
					objConfig.FSUsing = new string[ usingsNode.SelectNodes( "Using" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= usingsNode.SelectNodes( "Using" , xmlnsmgr ).Count ; i++)
					{
						objConfig.FSUsing[ i - 1 ] = usingsNode.SelectSingleNode( "Using[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}
				if (prefNode.SelectSingleNode( "Namespaces" , xmlnsmgr ) != null)
				{
					XmlNode nsNode = prefNode.SelectSingleNode( "Namespaces" , xmlnsmgr );
					objConfig.FSAddNamespaces = new string[ nsNode.SelectNodes( "Namespace" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= nsNode.SelectNodes( "Namespace" , xmlnsmgr ).Count ; i++)
					{
						objConfig.FSAddNamespaces[ i - 1 ] = nsNode.SelectSingleNode( "Namespace[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}

				if (prefNode.SelectSingleNode( "Methods" , xmlnsmgr ) != null)
				{


					objConfig.FSCodeMethods = new ConfigValues.codeMethods[ prefNode.SelectNodes( "Methods" , xmlnsmgr ).Count ];
					for (int j = 1 ; j <= objConfig.FSCodeMethods.Length ; j++)
					{

						XmlNode methNode = prefNode.SelectSingleNode( "Methods[" + j + "]" );
						if (methNode != null)
						{
							objConfig.FSCodeMethods[ j - 1 ] = new ConfigValues.codeMethods( );
							if (methNode.Attributes[ "region" ] != null) objConfig.FSCodeMethods[ j - 1 ].Region = methNode.Attributes[ "region" ].Value;
							if (methNode.SelectNodes( "Method" , xmlnsmgr ) != null)
							{
								objConfig.FSCodeMethods[ j - 1 ].CodeMethod = new ConfigValues.codeMethod[ methNode.SelectNodes( "Method" , xmlnsmgr ).Count ];

								for (int i = 1 ; i <= methNode.SelectNodes( "Method" , xmlnsmgr ).Count ; i++)
								{
									objConfig.FSCodeMethods[ j - 1 ].CodeMethod[ i - 1 ] = new ConfigValues.codeMethod( );
									objConfig.FSCodeMethods[ j - 1 ].CodeMethod[ i - 1 ].Code = methNode.SelectSingleNode( "Method[" + i + "]" , xmlnsmgr ).InnerText;
									if (methNode.SelectSingleNode( "Method[" + i + "]" , xmlnsmgr ).Attributes[ "constructor" ] != null) objConfig.FSCodeMethods[ j - 1 ].CodeMethod[ i - 1 ].Constructor =
																																																											 System.Convert.ToBoolean( methNode.SelectSingleNode( "Method[" + i + "]" , xmlnsmgr ).Attributes[ "constructor" ].Value );
									else objConfig.FSCodeMethods[ j - 1 ].CodeMethod[ i - 1 ].Constructor = false;
								}
							}
						}
					}
				}
				else objConfig.FSCodeMethods = new ConfigValues.codeMethods[ 0 ];
				if (prefNode.SelectSingleNode( "Variables" , xmlnsmgr ) != null)
				{
					XmlNode varNode = prefNode.SelectSingleNode( "Variables" , xmlnsmgr );

					objConfig.FSVariables = new string[ varNode.SelectNodes( "Variable" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= objConfig.FSVariables.Length ; i++)
					{
						objConfig.FSVariables[ i - 1 ] = varNode.SelectSingleNode( "Variable[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}
				#endregion

				#region Formscript specific
				if (prefNode.SelectSingleNode( "ImpMethods" , xmlnsmgr ) != null)
				{
					XmlNode impNode = prefNode.SelectSingleNode( "ImpMethods" );
					objConfig.FSMethods = new ConfigValues.fsMethods( );
					if (impNode.SelectSingleNode( "Region" , xmlnsmgr ) != null) objConfig.FSMethods.Region = impNode.SelectSingleNode( "Region" , xmlnsmgr ).InnerText;
					if (impNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FSMethods.Prefix = impNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
					if (impNode.SelectSingleNode( "AddForm" , xmlnsmgr ) != null)
					{
						objConfig.FSMethods.AddForm = new ConfigValues.fsMethod( );
						XmlNode methNode = impNode.SelectSingleNode( "AddForm" , xmlnsmgr );
						if (methNode.Attributes[ "UseTryCatch" ] != null) objConfig.FSMethods.AddForm.TryCatch = System.Convert.ToBoolean( methNode.Attributes[ "UseTryCatch" ].Value );
						else objConfig.FSMethods.AddForm.TryCatch = false;
						if (methNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FSMethods.AddForm.Prefix = methNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
						if (methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ) != null)
						{
							objConfig.FSMethods.AddForm.UseDefault = System.Convert.ToBoolean( methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ).InnerText );
							if (objConfig.FSMethods.AddForm.UseDefault)
							{
								objConfig.FSMethods.AddForm.Code = "object AddFormData(IRForm form, object recordsets, ref object parameterList)" + Environment.NewLine +
																										"{" + Environment.NewLine +
																										"\treturn form.DoAddFormData(recordsets, ref parameterList);" + Environment.NewLine +
																										"}";
							}
						}
						else if (methNode.SelectSingleNode( "Code" , xmlnsmgr ) != null) objConfig.FSMethods.AddForm.Code = methNode.SelectSingleNode( "Code" , xmlnsmgr ).InnerText;
					}
					if (impNode.SelectSingleNode( "DeleteForm" , xmlnsmgr ) != null)
					{
						objConfig.FSMethods.DeleteForm = new ConfigValues.fsMethod( );
						XmlNode methNode = impNode.SelectSingleNode( "DeleteForm" , xmlnsmgr );
						if (methNode.Attributes[ "UseTryCatch" ] != null) objConfig.FSMethods.DeleteForm.TryCatch = System.Convert.ToBoolean( methNode.Attributes[ "UseTryCatch" ].Value );
						if (methNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FSMethods.DeleteForm.Prefix = methNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
						else objConfig.FSMethods.DeleteForm.TryCatch = false;
						if (methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ) != null)
						{
							objConfig.FSMethods.DeleteForm.UseDefault = System.Convert.ToBoolean( methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ).InnerText );
							if (objConfig.FSMethods.DeleteForm.UseDefault)
							{
								objConfig.FSMethods.DeleteForm.Code = "void DeleteFormData(IRForm form, object recordId, ref object parameterList)" + Environment.NewLine +
																																"{" + Environment.NewLine +
																																"\tform.DoDeleteFormData(recordId, ref parameterList);" + Environment.NewLine +
																																"}";
							}
						}
						else if (methNode.SelectSingleNode( "Code" , xmlnsmgr ) != null) objConfig.FSMethods.DeleteForm.Code = methNode.SelectSingleNode( "Code" , xmlnsmgr ).InnerText;
					}
					if (impNode.SelectSingleNode( "Execute" , xmlnsmgr ) != null)
					{
						objConfig.FSMethods.Execute = new ConfigValues.fsMethod( );
						XmlNode methNode = impNode.SelectSingleNode( "Execute" , xmlnsmgr );
						if (methNode.Attributes[ "UseTryCatch" ] != null) objConfig.FSMethods.Execute.TryCatch = System.Convert.ToBoolean( methNode.Attributes[ "UseTryCatch" ].Value );
						if (methNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FSMethods.Execute.Prefix = methNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
						else objConfig.FSMethods.Execute.TryCatch = false;
						if (methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ) != null)
						{
							objConfig.FSMethods.Execute.UseDefault = System.Convert.ToBoolean( methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ).InnerText );
							if (objConfig.FSMethods.Execute.UseDefault)
							{
								objConfig.FSMethods.Execute.Code = "void Execute(IRForm form, string methodName, ref object parameterList)" + Environment.NewLine +
																														"{" + Environment.NewLine +
																														"\tthrow new PivotalApplicationException(methodName + \" not implemented\");" + Environment.NewLine +
																														"}";
							}
						}
						else if (methNode.SelectSingleNode( "Code" , xmlnsmgr ) != null) objConfig.FSMethods.Execute.Code = methNode.SelectSingleNode( "Code" , xmlnsmgr ).InnerText;
					}
					if (impNode.SelectSingleNode( "LoadForm" , xmlnsmgr ) != null)
					{
						objConfig.FSMethods.LoadForm = new ConfigValues.fsMethod( );
						XmlNode methNode = impNode.SelectSingleNode( "LoadForm" , xmlnsmgr );
						if (methNode.Attributes[ "UseTryCatch" ] != null) objConfig.FSMethods.LoadForm.TryCatch = System.Convert.ToBoolean( methNode.Attributes[ "UseTryCatch" ].Value );
						if (methNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FSMethods.LoadForm.Prefix = methNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
						else objConfig.FSMethods.LoadForm.TryCatch = false;
						if (methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ) != null)
						{
							objConfig.FSMethods.LoadForm.UseDefault = System.Convert.ToBoolean( methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ).InnerText );
							if (objConfig.FSMethods.LoadForm.UseDefault)
							{
								objConfig.FSMethods.LoadForm.Code = "object LoadFormData(IRForm form, object recordId, ref object parameterList)" + Environment.NewLine +
																														"{" + Environment.NewLine +
																														"\treturn form.DoLoadFormData(recordId, ref parameterList);" + Environment.NewLine +
																														"}";
							}
						}
						else if (methNode.SelectSingleNode( "Code" , xmlnsmgr ) != null) objConfig.FSMethods.LoadForm.Code = methNode.SelectSingleNode( "Code" , xmlnsmgr ).InnerText;
					}
					if (impNode.SelectSingleNode( "NewForm" , xmlnsmgr ) != null)
					{
						objConfig.FSMethods.NewForm = new ConfigValues.fsMethod( );
						XmlNode methNode = impNode.SelectSingleNode( "Execute" , xmlnsmgr );
						if (methNode.Attributes[ "UseTryCatch" ] != null) objConfig.FSMethods.NewForm.TryCatch = System.Convert.ToBoolean( methNode.Attributes[ "UseTryCatch" ].Value );
						if (methNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FSMethods.NewForm.Prefix = methNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
						else objConfig.FSMethods.NewForm.TryCatch = false;
						if (methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ) != null)
						{
							objConfig.FSMethods.NewForm.UseDefault = System.Convert.ToBoolean( methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ).InnerText );
							if (objConfig.FSMethods.NewForm.UseDefault)
							{
								objConfig.FSMethods.NewForm.Code = "object NewFormData(IRForm form, ref object parameterList)" + Environment.NewLine +
																														"{" + Environment.NewLine +
																														"\treturn form.DoNewFormData(ref parameterList);" + Environment.NewLine +
																														"}";
							}
						}
						else if (methNode.SelectSingleNode( "Code" , xmlnsmgr ) != null) objConfig.FSMethods.NewForm.Code = methNode.SelectSingleNode( "Code" , xmlnsmgr ).InnerText;
					}

					if (impNode.SelectSingleNode( "NewSecondary" , xmlnsmgr ) != null)
					{
						objConfig.FSMethods.NewSec = new ConfigValues.fsMethod( );
						XmlNode methNode = impNode.SelectSingleNode( "NewSecondary" , xmlnsmgr );
						if (methNode.Attributes[ "UseTryCatch" ] != null) objConfig.FSMethods.NewSec.TryCatch = System.Convert.ToBoolean( methNode.Attributes[ "UseTryCatch" ].Value );
						if (methNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FSMethods.NewSec.Prefix = methNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
						else objConfig.FSMethods.NewSec.TryCatch = false;
						if (methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ) != null)
						{
							objConfig.FSMethods.NewSec.UseDefault = System.Convert.ToBoolean( methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ).InnerText );
							if (objConfig.FSMethods.NewSec.UseDefault)
							{
								objConfig.FSMethods.NewSec.Code = "void NewSecondaryData(IRForm form, object secondaryName, ref object parameterList, ref Recordset recordset)" + Environment.NewLine +
																												"{" + Environment.NewLine +
																												"\tform.DoNewSecondaryData(secondaryName, ref parameterList, recordset);" + Environment.NewLine +
																												"}";
							}
						}
						else if (methNode.SelectSingleNode( "Code" , xmlnsmgr ) != null) objConfig.FSMethods.NewSec.Code = methNode.SelectSingleNode( "Code" , xmlnsmgr ).InnerText;
					}

					if (impNode.SelectSingleNode( "SaveForm" , xmlnsmgr ) != null)
					{
						objConfig.FSMethods.SaveForm = new ConfigValues.fsMethod( );
						XmlNode methNode = impNode.SelectSingleNode( "SaveForm" , xmlnsmgr );
						if (methNode.Attributes[ "UseTryCatch" ] != null) objConfig.FSMethods.SaveForm.TryCatch = System.Convert.ToBoolean( methNode.Attributes[ "UseTryCatch" ].Value );
						if (methNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FSMethods.SaveForm.Prefix = methNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
						else objConfig.FSMethods.SaveForm.TryCatch = false;
						if (methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ) != null)
						{
							objConfig.FSMethods.SaveForm.UseDefault = System.Convert.ToBoolean( methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ).InnerText );
							if (objConfig.FSMethods.SaveForm.UseDefault)
							{
								objConfig.FSMethods.SaveForm.Code = "void SaveFormData(IRForm form, object recordsets, ref object parameterList)" + Environment.NewLine +
																																"{" + Environment.NewLine +
																																"\t\tform.DoSaveFormData(recordsets, ref parameterList);" + Environment.NewLine +
																																"}";
							}
						}
						else if (methNode.SelectSingleNode( "Code" , xmlnsmgr ) != null) objConfig.FSMethods.SaveForm.Code = methNode.SelectSingleNode( "Code" , xmlnsmgr ).InnerText;
					}
					if (impNode.SelectSingleNode( "SetSystem" , xmlnsmgr ) != null)
					{
						objConfig.FSMethods.SetSystem = new ConfigValues.fsMethod( );
						XmlNode methNode = impNode.SelectSingleNode( "SetSystem" , xmlnsmgr );
						if (methNode.Attributes[ "UseTryCatch" ] != null) objConfig.FSMethods.SetSystem.TryCatch = System.Convert.ToBoolean( methNode.Attributes[ "UseTryCatch" ].Value );
						if (methNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FSMethods.SetSystem.Prefix = methNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
						else objConfig.FSMethods.SetSystem.TryCatch = false;
						if (methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ) != null)
						{
							objConfig.FSMethods.SetSystem.UseDefault = System.Convert.ToBoolean( methNode.SelectSingleNode( "UseDefault" , xmlnsmgr ).InnerText );
							if (objConfig.FSMethods.SetSystem.UseDefault)
							{
								objConfig.FSMethods.SetSystem.Code = "void SetSystem(Pivotal.Interop.RDALib.RSystem system)" + Environment.NewLine +
																														"{" + Environment.NewLine +
																														"\tm_rdaSystem = (IRSystem7)system;" + Environment.NewLine +
																														"}";
							}
						}
						else if (methNode.SelectSingleNode( "Code" , xmlnsmgr ) != null) objConfig.FSMethods.SetSystem.Code = methNode.SelectSingleNode( "Code" , xmlnsmgr ).InnerText;
					}
				}

				#endregion
			}

			#endregion

			#region Get values for Form parameters
			prefNode = root.SelectSingleNode( "Form" , xmlnsmgr );
			if (prefNode != null)
			{
				if (prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.FormPrefix = prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ) != null) objConfig.FormSuffix = prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ) != null) objConfig.CapForm = System.Convert.ToBoolean( prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ).InnerText );
				if (prefNode.SelectSingleNode( "Region" , xmlnsmgr ) != null) objConfig.FormRegion = prefNode.SelectSingleNode( "Region" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr ) != null)
				{
					XmlNode prefixNode = prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr );

					objConfig.FormPrefixRemove = new string[ prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ; i++)
					{
						objConfig.FormPrefixRemove[ i - 1 ] = prefixNode.SelectSingleNode( "Prefix[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}
				if (prefNode.SelectSingleNode( "ReplaceChars" , xmlnsmgr ) != null)
				{
					XmlNode rcNode = prefNode.SelectSingleNode( "ReplaceChars" , xmlnsmgr );
					objConfig.FormReplaceChars = new string[ rcNode.SelectNodes( "Char" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= rcNode.SelectNodes( "Char" , xmlnsmgr ).Count ; i++)
					{
						if (rcNode.SelectSingleNode( "Char[" + i + "]" , xmlnsmgr ).InnerText.ToUpper( ).Equals( "SPACE" )) objConfig.FormReplaceChars[ i - 1 ] = " ";
						else objConfig.FormReplaceChars[ i - 1 ] = rcNode.SelectSingleNode( "Char[" + i + "]" , xmlnsmgr ).InnerText;
					}
					if (rcNode.SelectSingleNode( "ReplaceWith" , xmlnsmgr ) != null) objConfig.FormReplaceWith = rcNode.SelectSingleNode( "ReplaceWith" , xmlnsmgr ).InnerText;
					if (rcNode.SelectSingleNode( "RemoveWithCharsEnd" , xmlnsmgr ) != null) objConfig.FormReplaceEndChars = System.Convert.ToBoolean( rcNode.SelectSingleNode( "RemoveWithCharsEnd" , xmlnsmgr ).InnerText );
					if (rcNode.SelectSingleNode( "RemoveWithCharsStart" , xmlnsmgr ) != null) objConfig.FormReplaceStartChars = System.Convert.ToBoolean( rcNode.SelectSingleNode( "RemoveWithCharsStart" , xmlnsmgr ).InnerText );
				}

			}

			#endregion

			#region Get values for Disconnected Field parameters
			prefNode = root.SelectSingleNode( "DiscFormField" , xmlnsmgr );
			if (prefNode != null)
			{
				if (prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.DiscPrefix = prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ) != null) objConfig.DiscSuffix = prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ) != null) objConfig.CapDisc = System.Convert.ToBoolean( prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ).InnerText );
				if (prefNode.SelectSingleNode( "Region" , xmlnsmgr ) != null) objConfig.DiscRegion = prefNode.SelectSingleNode( "Region" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "SubClass" , xmlnsmgr ) != null)
				{
					XmlNode scNode = prefNode.SelectSingleNode( "SubClass" , xmlnsmgr );
					if (scNode.SelectSingleNode( "Name" , xmlnsmgr ) != null) objConfig.DiscSubClass = scNode.SelectSingleNode( "Name" , xmlnsmgr ).InnerText;
					if (scNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.DiscSubClassPrefix = scNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
				}
				if (prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr ) != null)
				{
					XmlNode prefixNode = prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr );

					objConfig.DiscPrefixRemove = new string[ prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ; i++)
					{
						objConfig.DiscPrefixRemove[ i - 1 ] = prefixNode.SelectSingleNode( "Prefix[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}
				if (prefNode.SelectSingleNode( "ReplaceChars" , xmlnsmgr ) != null)
				{
					XmlNode rcNode = prefNode.SelectSingleNode( "ReplaceChars" , xmlnsmgr );
					objConfig.DiscReplaceChars = new string[ rcNode.SelectNodes( "Char" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= rcNode.SelectNodes( "Char" , xmlnsmgr ).Count ; i++)
					{
						if (rcNode.SelectSingleNode( "Char[" + i + "]" , xmlnsmgr ).InnerText.ToUpper( ).Equals( "SPACE" )) objConfig.DiscReplaceChars[ i - 1 ] = " ";
						else objConfig.DiscReplaceChars[ i - 1 ] = rcNode.SelectSingleNode( "Char[" + i + "]" , xmlnsmgr ).InnerText;
					}
					if (rcNode.SelectSingleNode( "ReplaceWith" , xmlnsmgr ) != null) objConfig.DiscReplaceWith = rcNode.SelectSingleNode( "ReplaceWith" , xmlnsmgr ).InnerText;
					if (rcNode.SelectSingleNode( "RemoveWithCharsEnd" , xmlnsmgr ) != null) objConfig.DiscReplaceEndChars = System.Convert.ToBoolean( rcNode.SelectSingleNode( "RemoveWithCharsEnd" , xmlnsmgr ).InnerText );
					if (rcNode.SelectSingleNode( "RemoveWithCharsStart" , xmlnsmgr ) != null) objConfig.DiscReplaceStartChars = System.Convert.ToBoolean( rcNode.SelectSingleNode( "RemoveWithCharsStart" , xmlnsmgr ).InnerText );
				}
			}

			#endregion

			#region Get values for Tab parameters
			prefNode = root.SelectSingleNode( "Tab" , xmlnsmgr );
			if (prefNode != null)
			{
				if (prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.TabPrefix = prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ) != null) objConfig.TabSuffix = prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ) != null) objConfig.CapTab = System.Convert.ToBoolean( prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ).InnerText );
				if (prefNode.SelectSingleNode( "Region" , xmlnsmgr ) != null) objConfig.TabRegion = prefNode.SelectSingleNode( "Region" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr ) != null)
				{
					XmlNode prefixNode = prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr );

					objConfig.TabPrefixRemove = new string[ prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ; i++)
					{
						objConfig.TabPrefixRemove[ i - 1 ] = prefixNode.SelectSingleNode( "Prefix[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}
				if (prefNode.SelectSingleNode( "ReplaceChars" , xmlnsmgr ) != null)
				{
					XmlNode rcNode = prefNode.SelectSingleNode( "ReplaceChars" , xmlnsmgr );
					objConfig.TabReplaceChars = new string[ rcNode.SelectNodes( "Char" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= rcNode.SelectNodes( "Char" , xmlnsmgr ).Count ; i++)
					{
						if (rcNode.SelectSingleNode( "Char[" + i + "]" , xmlnsmgr ).InnerText.ToUpper( ).Equals( "SPACE" )) objConfig.TabReplaceChars[ i - 1 ] = " ";
						else objConfig.TabReplaceChars[ i - 1 ] = rcNode.SelectSingleNode( "Char[" + i + "]" , xmlnsmgr ).InnerText;
					}
					if (rcNode.SelectSingleNode( "ReplaceWith" , xmlnsmgr ) != null) objConfig.TabReplaceWith = rcNode.SelectSingleNode( "ReplaceWith" , xmlnsmgr ).InnerText;
					if (rcNode.SelectSingleNode( "RemoveWithCharsEnd" , xmlnsmgr ) != null) objConfig.TabReplaceEndChars = System.Convert.ToBoolean( rcNode.SelectSingleNode( "RemoveWithCharsEnd" , xmlnsmgr ).InnerText );
					if (rcNode.SelectSingleNode( "RemoveWithCharsStart" , xmlnsmgr ) != null) objConfig.TabReplaceStartChars = System.Convert.ToBoolean( rcNode.SelectSingleNode( "RemoveWithCharsStart" , xmlnsmgr ).InnerText );
				}
			}

			#endregion

			#region Get values for Segment  parameters
			prefNode = root.SelectSingleNode( "Segment" , xmlnsmgr );
			if (prefNode != null)
			{
				if (prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ) != null) objConfig.SegPrefix = prefNode.SelectSingleNode( "Prefix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ) != null) objConfig.SegSuffix = prefNode.SelectSingleNode( "Suffix" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ) != null) objConfig.CapSeg = System.Convert.ToBoolean( prefNode.SelectSingleNode( "Capitalise" , xmlnsmgr ).InnerText );
				if (prefNode.SelectSingleNode( "Region" , xmlnsmgr ) != null) objConfig.SegRegion = prefNode.SelectSingleNode( "Region" , xmlnsmgr ).InnerText;
				if (prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr ) != null)
				{
					XmlNode prefixNode = prefNode.SelectSingleNode( "PrefixRemove" , xmlnsmgr );

					objConfig.SegPrefixRemove = new string[ prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= prefixNode.SelectNodes( "Prefix" , xmlnsmgr ).Count ; i++)
					{
						objConfig.SegPrefixRemove[ i - 1 ] = prefixNode.SelectSingleNode( "Prefix[" + i + "]" , xmlnsmgr ).InnerText;
					}
				}
				if (prefNode.SelectSingleNode( "ReplaceChars" , xmlnsmgr ) != null)
				{
					XmlNode rcNode = prefNode.SelectSingleNode( "ReplaceChars" , xmlnsmgr );
					objConfig.SegReplaceChars = new string[ rcNode.SelectNodes( "Char" , xmlnsmgr ).Count ];
					for (int i = 1 ; i <= rcNode.SelectNodes( "Char" , xmlnsmgr ).Count ; i++)
					{
						if (rcNode.SelectSingleNode( "Char[" + i + "]" , xmlnsmgr ).InnerText.ToUpper( ).Equals( "SPACE" )) objConfig.SegReplaceChars[ i - 1 ] = " ";
						else objConfig.SegReplaceChars[ i - 1 ] = rcNode.SelectSingleNode( "Char[" + i + "]" , xmlnsmgr ).InnerText;
					}
					if (rcNode.SelectSingleNode( "ReplaceWith" , xmlnsmgr ) != null) objConfig.SegReplaceWith = rcNode.SelectSingleNode( "ReplaceWith" , xmlnsmgr ).InnerText;
					if (rcNode.SelectSingleNode( "RemoveWithCharsEnd" , xmlnsmgr ) != null) objConfig.SegReplaceEndChars = System.Convert.ToBoolean( rcNode.SelectSingleNode( "RemoveWithCharsEnd" , xmlnsmgr ).InnerText );
					if (rcNode.SelectSingleNode( "RemoveWithCharsStart" , xmlnsmgr ) != null) objConfig.SegReplaceStartChars = System.Convert.ToBoolean( rcNode.SelectSingleNode( "RemoveWithCharsStart" , xmlnsmgr ).InnerText );
				}
			}

			#endregion
		}
	}
}
